package com.yanqu.road.server.cmd.activity.stronghold.cross;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.seasontask.SeasonTaskConditionData;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.strongholdwar.StrongholdModule;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.math.BigInteger;

@Cmd(code = GameProtocol.S_CROSS_STRONGHOLD_WILD_MOVE, desc = "")
public class CrossMoveWildResultCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        StrongholdWarProto.CrossMoveToStrongholdRespMsg msg = StrongholdWarProto.CrossMoveToStrongholdRespMsg.parseFrom(packet.getBytes());
        ret = msg.getRet();
        if (ret == 0) {
            ActivityInfo activityInfo = StrongholdActivityMgr.getActivityInfo();
            if (activityInfo != null) {
                player.getModule(StrongholdModule.class).reducePower(StrongholdActivityMgr.getMovePower(),2);
                SeasonTaskConditionData conditionData = new SeasonTaskConditionData(BigInteger.valueOf(activityInfo.getType()),BigInteger.valueOf(StrongholdActivityMgr.getMovePower()));
                player.notifyListener(eGamePlayerEventType.UnionFightCostStaminaTask.getValue(), conditionData);
            }
        }
        player.sendPacket(ClientProtocol.U_STRONGHOLD_WAR_WILD_MOVE, msg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
